/*
 * manejodorBits.cpp
 *
 *  Created on: 20/11/2009
 *      Author: root
 */

#include <iostream>
#include <string>
#include "../Util/Compresor/Arithmetic/Dynamic/StateControl.h"
#include  "../Util/Compresor/Arithmetic/Dynamic/BitManager.h"
#include <bitset>

using namespace std;

struct charBit {
	unsigned short b:1;
};

typedef charBit array[32];

class testBitManager {

public:
	void run() {
	StateControl stateControl;
	BitManager manejadorBits;




	unsigned int piso, techo;


	piso = ~0;
	piso = (piso>>1) -1 + 4096 +4095;
	techo= ~0;
	techo= (techo>>1)-1 +8192 + 127;

	cout<<"overflow y underflow al mismo tiempo"<<endl;

	manejadorBits.normalize();

	//stateControl.mostrarBinario(manejadorBits.getNormalizedFloor(), "piso bin normalilized");
	//stateControl.mostrarBinario(manejadorBits.getNormalizedRoof(), "techo bin normalized");

	manejadorBits.normalize();

	string compresion = manejadorBits.getCompressedString();

	unsigned int i;
	unsigned int j;
	unsigned char caracter;

	for(i=0;i<compresion.size();i++) {
		caracter = compresion[i];
		bitset<8> byte(caracter);

		for(j=0;j<8;j++)
			cout<<byte[7-j];
		cout<<" "<<static_cast<int>(caracter)<<"    ";
		cout<<compresion[i]<<endl;
	}


	charBit vector[32];
	for(i=0;i<32;i++) {
		vector[i].b=0;
	}

	for(i=0;i<32;i++) {
		cout<<vector[i].b;
	}

	cout<<endl;
	cout<<sizeof(array)<<endl;




	}

};
